<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../static/教师端.css">
    <link rel="stylesheet" href="../static/iconfont/iconfont.css">
    <title>惠州学院选课系统管理</title>
</head>
<body>
<div class="head">
    <div class="header">&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;<img width=36 height=36 src="../static/xh.png"/><img width=180 height=36 src="../static/wz.png"/>
        <a href="/admin/login"  class="exit"><i class="iconfont icon-tuichu"></i>退出登录</a></div>
</div>
<div class="big_box">
    <div class="wrap">
        <div class="seg"></div>
        <div class="item_title">
            <b>Administrator</b>
        </div>
        <div class = "seg"></div>
        <div class="item">
            <a href="getAllteacher"><i class="iconfont icon-yixuan" ></i>&ensp;教师信息管理</a>
        </div>
        <div class="item">
            <a href="getAllstudent"><i class="iconfont icon-fabu" ></i>&ensp;学生信息管理</a>
        </div>
    </div>
    <div class="main">
        <div class="row">
            <h1>
                信息管理
            </h1>
            &nbsp;&nbsp;<button class="button" style="background-color:#308ad9;border: 3px solid #308ad9;" onclick="add_stu()">添加</button><br>
            <div class="course_table" id="course_table">
                <table class="table" border="2">
                    <thead>
                    <tr>
                        <th>学号</th>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>密码</th>
                        <th>院系</th>
                        <th>专业</th>
                        <th>班级</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="student:${student}">
                        <td th:text="${student.studentID}"></td>
                        <td th:text="${student.name}"></td>
                        <td th:text="${student.sex}"></td>
                        <td th:text="${student.password}"></td>
                        <td th:text="${student.faculty}"></td>
                        <td th:text="${student.major}"></td>
                        <td th:text="${student.classname}"></td>
                        <td><a th:href="@{/admin/delstu(id=${student.Id})}">删除</a></td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <!--    添加信息-->
    <div class="modal" id="myModal" style="display: none;">
        <div class="modal-dialog">
            <form class="modal-content" action="/modify" method="post" id="Form" role="form">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" onclick="Default()">
                        <span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
                    </button>
                </div>
                <h4 class="modal-title" style="padding-left: 40px;">请填写新增学生信息</h4>
                <div class="modal-body1"style="padding-left: 40px;">
                    <form id="course_form">
                        <tr>
                            <td>学生ID：<input placeholder="学生ID" type="text" id="id" /><br/></td>
                            <td>学号：<input placeholder="学号" type="text" id="stu_id"/><br /></td>
                            <td>姓名：<input placeholder="姓名" type="text" id="stu_name"/><br /></td>
                            <td>性别：<input placeholder="性别" type="text" id="stu_sex"/><br /></td>
                            <td>密码：<input placeholder="密码" type="text" id="stu_password" value="123456" disabled="disabled"/><br /></td>
                            <td>院系：<input placeholder="院系" type="text" id="stu_faculty" /><br /></td>
                            <td>专业：<input placeholder="专业" type="text" id="stu_major" /><br /></td>
                            <td>班级：<input placeholder="班级" type="text" id="stu_class" /><br /></td>
                            <td>入学年份：<input placeholder="入学年份" type="text" id="stu_year" /></td>
                        </tr>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn_default" data-dismiss="modal" onclick="Default()">取消</button>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                    <button type="submit" class="btn_primary" onclick="add()">确定</button>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<script>
    function  Default() {
        document.getElementById("myModal").style.display="none";
        document.getElementById("myModal2").style.display="none";
    }
    function add_stu(){
        document.getElementById("myModal").style.display="block";}
    function add() {
         var id = document.getElementById("id").value;
         var stuid = document.getElementById("stu_id").value;
         var name = document.getElementById("stu_name").value;
         var sex = document.getElementById("stu_sex").value;
         var psw = document.getElementById("stu_password").value;
         var faculty = document.getElementById("stu_faculty").value;
         var major = document.getElementById("stu_major").value;
         var stuclass = document.getElementById("stu_class").value;
         var year = document.getElementById("stu_year").value;

         $.ajax({
             url:"/admin/addstu",
             type:"GET",
             data:{
                 id : id,
                 stuid : stuid,
                 name : name,
                 sex : sex,
                 psw : psw,
                 faculty : faculty,
                 major : major,
                 stuclass : stuclass,
                 year : year,
             },
             success:function (msg) {
                 if(msg=="yes") {
                     alert("添加成功！！！");
                     window.open("/admin/getAllstudent","_self");
                 }else alert("添加失败！！！");
             },
             error:function (error) {
                 alert("请检查网络连接！！！");

             }
         })
    }

    function logout() {
        $.ajax({
            async:false,
            type:"post",
            url:'/admin/login',
            contentType:"application/x-www-form-urlencoded;charset=utf-8",
            dataType:"text",
            complete:function(){
                window.location.reload();
            }
        })
    }
</script>
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<script>window.jp || document.write('<script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.24/assets/js/vendor/jquery.min.js"><\/script>')</script>
</html>